package site.zbox.tool.swing.xml.component;

import javax.swing.JComponent;
import javax.swing.JProgressBar;

import org.dom4j.Element;

import site.zbox.tool.lang.StringUtils;
import site.zbox.tool.lang.Version;
import site.zbox.tool.swing.xml.IComponentParser;

@Version("2021.08.12")
public class ProgressBarComponentParser implements IComponentParser {
    @Override
    public String name() {
        return "ProgressBar";
    }

    @Override
    public JComponent parse(Element element) {
        final JProgressBar progressBar = new JProgressBar();
        final String stringPainted = StringUtils.trimToEmpty(element.attributeValue("string-painted"));
        if (StringUtils.isNotEmpty(stringPainted)) {
            progressBar.setStringPainted("true".equalsIgnoreCase(stringPainted));
        }
        return progressBar;
    }
}
